cmake_minimum_required(VERSION 3.16)
project(opus_stream_server)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
set(SOCKPP_BUILD_STATIC ON)
set(SOCKPP_BUILD_SHARED OFF)
add_subdirectory(sockpp)

find_package(Threads)

find_package(PkgConfig REQUIRED)
pkg_check_modules(OPUS REQUIRED IMPORTED_TARGET opus)

#pkg_check_modules(PROTOBUF REQUIRED IMPORTED_TARGET protobuf)
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(stream.pb.cc stream.pb.h stream.proto)

add_executable(opus_stream_server
        server.cpp
        stream.pb.cc OpusDecoder.cpp OpusDecoder.h)

target_include_directories(opus_stream_server PRIVATE
        sockpp/include
        ${CMAKE_CURRENT_BINARY_DIR}
        ${OPUS_INCLUDE_DIRS}
        ${Protobuf_INCLUDE_DIR})
target_link_libraries(opus_stream_server
        sockpp-static
        ${CMAKE_THREAD_LIBS_INIT}
        ${OPUS_LINK_LIBRARIES}
        ${Protobuf_LIBRARIES}
        )

add_executable(opus_stream_client
        client.cpp
        OpusDecoder.cpp
        stream.pb.cc)
target_include_directories(opus_stream_client PRIVATE
        sockpp/include
        ${CMAKE_CURRENT_BINARY_DIR}
        ${OPUS_INCLUDE_DIRS}
        ${Protobuf_INCLUDE_DIR})
target_link_libraries(opus_stream_client
        sockpp-static
        ${OPUS_LINK_LIBRARIES}
        ${Protobuf_LIBRARIES}
        )
